/*************************************************************************
	> File Name: client.cpp
	> Author: ma6174
	> Mail: ma6174@163.com 
	> Created Time: 2021年12月12日 星期日 16时32分11秒
 ************************************************************************/

#include <exception>
#include "inter.h"
using namespace std;

int main()
{
	PlayContext* context = new PlayContext("T 500 O 2 E 0.5 G 0.5 A 3 E 0.5 G 0.5 D 3 E 0.5 G 0.5 A 0.5 O 3 C 1 O 2 A 0.5 G 1 C 0.5 E 0.5 D 3");
	cout << "上海滩:" << endl;
	Expression* expression = nullptr;

	try
	{
		while (context->getText().length() > 0)
		{
			char c = context->getText()[0];
			switch (c)
			{
				case 'O':
					expression = new Scale();
					break;
				case 'T':
					expression = new Speed();
					break;
				default:
					expression = new Note();
					break;
			}
			expression->interpret(context);
		}
	}
	catch(const exception& e)
	{
		cerr << e.what() << endl;
	}
	cout << endl;
	return 0;
}
